package work.chief.dao.impl;

import work.chief.dao.CategoryDao;
import work.chief.entity.Category;
import work.chief.utils.DBUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CategoryDaoImpl implements CategoryDao {
    @Override
    public List<Category> selectCategory(int pageSize) {
        List<Category> categoryList =null;
        try {
            QueryRunner queryRunner= DBUtils.getInstance().getQrDb();
            String sql="select * from category limit ?";
            categoryList=queryRunner.query(sql,new BeanListHandler<Category>(Category.class),pageSize);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return categoryList;
    }
}
